package Pursuit_Client;

/**
 * @author Duyun Chen
 *
 */
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public abstract class PursuitManualAlgorithm extends KeyAdapter implements PursuitPlayer {
	
	private double acceleration = 0.000D;
	private double angularAcceleration = 0.000D;
	private double maxAcceleration = getMaxAcceleration();
	private double minAcceleration = getMinAcceleration();
	private double maxAngularAcceleration = getMaxAngularAcceleration();
	private double minAngularAcceleration = getMinAngularAcceleration();
	
	private final double LINEAR_INCREMENT = 0.005D;
	private final double ANGULAR_INCREMENT = 0.005D;
	
	//handles key press (specifically arrow keys)
	public void keyPressed(KeyEvent e) 
	{		
		switch (e.getKeyCode()) 
		{
			case (KeyEvent.VK_UP):
				acceleration += LINEAR_INCREMENT;
				break;
			case (KeyEvent.VK_DOWN):
				acceleration -= LINEAR_INCREMENT;
				break;
			case (KeyEvent.VK_LEFT):
				angularAcceleration -= ANGULAR_INCREMENT;
				break;
			case (KeyEvent.VK_RIGHT):
				angularAcceleration += ANGULAR_INCREMENT;
				break;
		}
	}
	
	public void update(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k, double l) {}
	
	public double getAcceleration() 
	{
		if (acceleration > maxAcceleration) 
			return acceleration = maxAcceleration;
		if (acceleration < minAcceleration) 
			return acceleration = minAcceleration;
		return acceleration;
	}
	
	public double getAngularAcceleration() 
	{
		if (angularAcceleration > maxAngularAcceleration) 
			return angularAcceleration = maxAngularAcceleration;
		if (angularAcceleration < minAngularAcceleration) 
			return angularAcceleration = minAngularAcceleration;
		return angularAcceleration;
	}
	
	public abstract String getRole();
	public abstract String toString();
	public abstract double getMaxAcceleration();
	public abstract double getMinAcceleration();
	public abstract double getMaxAngularAcceleration();
	public abstract double getMinAngularAcceleration();
}
